package gxdlxy.zx2202.chat5;

import java.time.Instant;
import java.time.LocalDate;

public class Example6 {
    public static void main(String[] args) {
        System.out.println(Instant.ofEpochMilli(System.currentTimeMillis()));
        // 解法一：
        int now = (int) (System.currentTimeMillis()/1000);
        int birth = (int) Instant.parse("1992-05-01T00:00:00Z").getEpochSecond();
        int day = (now - birth) / 60 / 60 / 24;
        System.out.println(day);
        // 解法二：1992-05-01
        int countDays = 0;
        LocalDate birthday = LocalDate.of(1992, 5, 1);
        if (birthday.isLeapYear())
            if (birthday.getMonthValue()<3)
                countDays++;
        countDays += 365 - birthday.getDayOfYear();
        birthday = birthday.plusYears(1);
        for(; birthday.getYear() < LocalDate.now().getYear();) {
            if (birthday.isLeapYear())
                countDays++;
            countDays+=365;
            birthday = birthday.plusYears(1);
        }
        countDays += LocalDate.now().getDayOfYear();
        System.out.println(countDays);
    }
}
